import math

def get(num):#-1=deficient, 0=perfect, 1=abundant
	ds = 0
	for x in range(1,int(math.sqrt(num))+1):
		if num % x == 0:
			ds = ds + x
			if num/x != x:
				ds = ds + num/x
	ds = ds - num
	if ds < num:
		return -1
	elif ds == num:
		return 0
	elif ds > num:
		return 1

def getp(r):
	s = set()
	for x in range(1,r+1):
		if get(x) == 1:
			s.add(x)
	return s

s = getp(28122)
nums = range(1,28123)
total = 0
for x in range(1,28123):
	test = 0
	for y in s:
		if x-y in s:
			test = 1
#			print(str(x)+": "+str(x)+"+"+str(x-y))
			break
	if test == 0:
		total = total + x
		
print(total)